//
//  WBTabBarController.m
//  微博项目
//
//  Created by ma c on 16/8/13.
//  Copyright (c) 2016年 beijing. All rights reserved.
//

#import "WBTabBarController.h"
#import "WBDiscoverTableViewController.h"
#import "WBHomeTableViewController.h"
#import "WBMessageTableViewController.h"
#import "WBProfileTableViewController.h"
#import "WBNavigationController.h"
#import "WBTabBar.h"

@interface WBTabBarController ()<WBTabBarDelegate>

@end

@implementation WBTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    WBHomeTableViewController * homeVC = [[WBHomeTableViewController alloc]init];
    [self addChildVC:homeVC title:@"首页" image:@"tabbar_home" selectedImage:@"tabbar_home_selected"];
    
    WBMessageTableViewController * messageVC = [[WBMessageTableViewController alloc]init];
    [self addChildVC:messageVC title:@"消息" image:@"tabbar_message_center" selectedImage:@"tabbar_message_center_selected"];
    
    WBDiscoverTableViewController * discoverVC = [[WBDiscoverTableViewController alloc]init];
    [self addChildVC:discoverVC title:@"发现" image:@"tabbar_discover" selectedImage:@"tabbar_discover_selected"];
    WBProfileTableViewController * profileVC = [[WBProfileTableViewController alloc]init];
    [self addChildVC:profileVC title:@"我" image:@"tabbar_profile" selectedImage:@"tabbar_profile_selected"];
    WBTabBar * tabBar = [[WBTabBar alloc]init];
    [self setValue:tabBar forKeyPath:@"tabBar"];
    
    
}

- (void)addChildVC:(UIViewController *)ChildVC title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
    ChildVC.title = title;
    //tabBarItem的图片。用绘制的方法
    ChildVC.tabBarItem.image = [UIImage imageNamed:image];
    //光标在该tabBarItem上时，即选择时候，的图片，用绘制的方法
    ChildVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    
    WBNavigationController * navVC = [[WBNavigationController alloc]initWithRootViewController:ChildVC];
    [self addChildViewController:navVC];
    
    
}

- (void)tabBarDidClickPlusButton:(WBTabBar *)tabBar{
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view.backgroundColor = [UIColor redColor];
    [self presentViewController:vc animated:YES completion:nil];
}


@end
